//related to header1.ui
var root = ui("$");// 或者var root = ui("root");
var nf = sm("do_Notification");
var app = sm('do_App');
var page = sm("do_Page");
var service_url = sm("do_Global");
var url  = service_url.getMemory("service_url");
var header_title = ui("header_title");
var gridData = mm("do_ListData");
var mData = page.getData();
var cacher = sm("do_DataCache");
page.on('back',function(){
	app.closePage();
});
 
page.on('loaded',function(){
	ui('mtype').text = mData.level_name;
	ui('mName').text = mData.nick_name;
	ui('username').text = mData.user_name;
	ui('balance').text = mData.balance;
	ui('mTime').text = formatDateTime(mData.current_login_time);
});
function formatDateTime(inputTime) {  
	    var date = new Date(inputTime);
	    var y = date.getFullYear();  
	    var m = date.getMonth() + 1;  
	    m = m < 10 ? ('0' + m) : m;  
	    var d = date.getDate();  
	    d = d < 10 ? ('0' + d) : d;  
	    var h = date.getHours();
	    h = h < 10 ? ('0' + h) : h;
	    var minute = date.getMinutes();
	    var second = date.getSeconds();
	    minute = minute < 10 ? ('0' + minute) : minute;  
	    second = second < 10 ? ('0' + second) : second; 
	    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;  
	};
//组件列表
 var listdata = mm("do_ListData");
//定义listview界面
var listView = ui("do_ListView_coupons");
//绑定数据
listView.bindItems(listdata);
//需要Cell对应的模板UI文件组
listView.templates="source://view/memberdetails/cell.ui";

loadData();

//http://116.62.224.105/marketing/index.php?s=/admin/member/accountdetail
function loadData(){
	var http = mm("do_Http");
	http.method = "POST";
	http.timeout = 30000;
	http.contentType = "application/x-www-form-urlencoded";
	http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
	var token = cacher.loadData("token");
	http.setRequestHeader("Cookie", token+"");
	http.url = url+"index.php?s=/admin/member/accountdetail";
	http.contentType = "application/x-www-form-urlencoded";
	http.body = "member_id="+mData.uid;

	http.on("success", function(data) {
		listdata.addData(data);
		listView.bindItems(listdata);
		listView.refreshItems();
		//app.openPage("source://view/index.ui");
	});
	http.request();
	
}


//上下滑动，恢复headerview和footerview
listView.rebound();

var do_Button_Confirm = ui("do_Button_Confirm");
do_Button_Confirm.on("touch",function(){
	app.openPage("source://view/index.ui");
})


